1
|
|
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; |
2
|
|
|
import { Task } from '../Task/Task.entity'; |
3
|
|
|
import { Project } from '../Project/Project.entity'; |
4
|
|
|
import { User } from '../HumanResource/User/User.entity'; |
5
|
|
|
|
6
|
|
|
export enum EventType { |
7
|
|
|
MISSION = 'mission', |
8
|
|
|
SUPPORT = 'support', |
9
|
|
|
DOJO = 'dojo', |
10
|
|
|
FORMATION_CONFERENCE = 'formationConference', |
11
|
|
|
OTHER = 'other' |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
@Entity() |
15
|
|
|
export class Event { |
16
|
|
|
public static readonly MAXIMUM_TIMESPENT_PER_DAY: number = 720; |
17
|
|
|
|
18
|
|
|
@PrimaryGeneratedColumn('uuid') |
19
|
|
|
private id: string; |
20
|
|
|
|
21
|
|
|
@Column('enum', {enum: EventType, nullable: false}) |
22
|
|
|
private type: EventType; |
23
|
|
|
|
24
|
|
|
@Column({type: 'integer', nullable: false, comment: 'Stored in minutes'}) |
25
|
|
|
private time: number; |
26
|
|
|
|
27
|
|
|
@Column({type: 'date', nullable: false}) |
28
|
|
|
private date: string; |
29
|
|
|
|
30
|
|
|
@Column({type: 'boolean', default: true}) |
31
|
|
|
private billable: boolean; |
32
|
|
|
|
33
|
|
|
@Column({type: 'varchar', nullable: true}) |
34
|
|
|
private summary: string; |
35
|
|
|
|
36
|
|
|
@ManyToOne(type => Project, {nullable: true}) |
37
|
|
|
private project: Project; |
38
|
|
|
|
39
|
|
|
@ManyToOne(type => Task, {nullable: true}) |
40
|
|
|
private task: Task; |
41
|
|
|
|
42
|
|
|
@ManyToOne(type => User, {nullable: false}) |
43
|
|
|
private user: User; |
44
|
|
|
|
45
|
|
|
constructor( |
46
|
|
|
type: EventType, |
47
|
|
|
user: User, |
48
|
|
|
time: number, |
49
|
|
|
date: string, |
50
|
|
|
billable: boolean, |
51
|
|
|
project?: Project, |
52
|
|
|
task?: Task, |
53
|
|
|
summary?: string |
54
|
|
|
) { |
55
|
|
|
this.type = type; |
56
|
|
|
this.user = user; |
57
|
|
|
this.time = time; |
58
|
|
|
this.date = date; |
59
|
|
|
this.billable = billable; |
60
|
|
|
this.project = project; |
61
|
|
|
this.task = task; |
62
|
|
|
this.summary = summary; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public getId(): string { |
66
|
|
|
return this.id; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public getType(): string { |
70
|
|
|
return this.type; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public getTime(): number { |
74
|
|
|
return this.time; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public getDate(): string { |
78
|
|
|
return this.date; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public isBillable(): boolean { |
82
|
|
|
return this.billable; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public getSummary(): string | null { |
86
|
|
|
return this.summary; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public getProject(): Project | null { |
90
|
|
|
return this.project; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public getTask(): Task | null { |
94
|
|
|
return this.task; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public getUser(): User { |
98
|
|
|
return this.user; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public update( |
102
|
|
|
type: EventType, |
103
|
|
|
time: number, |
104
|
|
|
billable: boolean, |
105
|
|
|
project?: Project, |
106
|
|
|
task?: Task, |
107
|
|
|
summary?: string |
108
|
|
|
): void { |
109
|
|
|
this.type = type; |
110
|
|
|
this.time = time; |
111
|
|
|
this.billable = billable; |
112
|
|
|
this.project = project; |
113
|
|
|
this.task = task; |
114
|
|
|
this.summary = summary; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|